package com.ChainBizPro.system.service.impl;

import com.ChainBizPro.system.common.ErrorCode;
import com.ChainBizPro.system.exception.BusinessException;
import com.ChainBizPro.system.mapper.OrderaftersalesMapper;
import com.ChainBizPro.system.model.domain.Orderaftersales;
import com.ChainBizPro.system.model.dto.Order.OrderaftersalesQueryRequest;
import com.ChainBizPro.system.model.vo.OrderaftersalesVO;
import com.ChainBizPro.system.service.OrderaftersalesService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author liusijia
* @description 针对表【OrderAfterSales(订单售后)】的数据库操作Service实现
* @createDate 2024-12-16 20:17:05
*/
@Service
public class OrderaftersalesServiceImpl extends ServiceImpl<OrderaftersalesMapper, Orderaftersales>
    implements OrderaftersalesService {

    @Resource
    private OrderaftersalesMapper orderaftersalesMapper;

    @Override
    public Page<OrderaftersalesVO> getQueryWrapperByUser(Page<OrderaftersalesVO> pageParam, OrderaftersalesQueryRequest orderaftersalesQueryRequest, Long userId) {
        // 自定义分页查询
        List<OrderaftersalesVO> orderaftersalesVOS = orderaftersalesMapper.getQueryWrapperByMy(pageParam, orderaftersalesQueryRequest, userId);
        if (orderaftersalesVOS == null) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询失败");
        }
        // 设置分页结果
        pageParam.setRecords(orderaftersalesVOS);
        return pageParam;
    }

    @Override
    public Page<OrderaftersalesVO> getQueryWrapperByAdmin(Page<OrderaftersalesVO> pageParam, OrderaftersalesQueryRequest orderaftersalesQueryRequest) {
        // 自定义分页查询
        List<OrderaftersalesVO> orderaftersalesVOS = orderaftersalesMapper.getQueryWrapperByAdmin(pageParam, orderaftersalesQueryRequest);
        if (orderaftersalesVOS == null) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询失败");
        }
        // 设置分页结果
        pageParam.setRecords(orderaftersalesVOS);
        return pageParam;
    }

    @Override
    public Page<OrderaftersalesVO> getQueryWrapperByContact(Page<OrderaftersalesVO> pageParam, OrderaftersalesQueryRequest orderaftersalesQueryRequest, Long userId) {
        // 自定义分页查询
        List<OrderaftersalesVO> orderaftersalesVOS = orderaftersalesMapper.getQueryWrapperByContact(pageParam, orderaftersalesQueryRequest, userId);
        if (orderaftersalesVOS == null) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询失败");
        }
        // 设置分页结果
        pageParam.setRecords(orderaftersalesVOS);
        return pageParam;
    }
}




